program blank;
{$mode objfpc}{$H+}
uses 
  math,SysUtils,facecat;  
var
  appPaint:FCPaint;

{重绘背景的实现方法
inView:视图
paint:绘图对象
clipRect:裁剪区域}
procedure OnPaint(var inView:FCView; var paint:FCPaint; clipRect:FCRect);
begin
  OnPaintDefault(inView, paint, clipRect);
end;

{重绘边框的实现方法
inView:视图
paint:绘图对象
clipRect:裁剪区域}
procedure OnPaintBorder(var inView:FCView; var paint:FCPaint; clipRect:FCRect);
begin
  OnPaintBorderDefault(inView, paint, clipRect);
end;

{鼠标按下的方法
inView:视图
mp:坐标
buttons:按钮
clicks:点击次数
delta:滚轮值}
procedure OnMouseDown(var inView:FCView; mp:FCPoint; buttons:integer; clicks:integer; delta:integer);
begin
  OnMouseDownDefault(inView, mp, buttons, clicks, delta);
end;

{鼠标抬起的方法
inView:视图
mp:坐标
buttons:按钮
clicks:点击次数
delta:滚轮值}
procedure OnMouseUp(var inView:FCView; mp:FCPoint; buttons:integer; clicks:integer; delta:integer);
begin
  OnMouseUpDefault(inView, mp, buttons, clicks, delta);
end;

{鼠标移动的方法
inView:视图
mp:坐标
buttons:按钮
clicks:点击次数
delta:滚轮值}
procedure OnMouseMove(var inView:FCView; mp:FCPoint; buttons:integer; clicks:integer; delta:integer);
begin
  OnMouseMoveDefault(inView, mp, buttons, clicks, delta);
end;

{鼠标点击的方法
inView:视图
firstTouch:是否第一次触摸
firstPoint:第一次触摸的坐标
secondTouch:是否第二次触摸
secondPoint:第二次触摸的坐标
clicks:点击次数}
procedure OnClick(var inView:FCView; firstTouch:boolean; firstPoint:FCPoint; secondTouch:boolean; secondPoint:FCPoint; clicks:integer);
begin
  OnClickDefault(inView, firstTouch, firstPoint, secondTouch, secondPoint, clicks);
end;

{视图的鼠标滚动方法
view 视图
mp 坐标
buttons 按钮 0未按下 1左键 2右键
clicks 点击次数
delta 滚轮值}
procedure OnMouseWheel(var inView:FCView; mp:FCPoint; buttons:integer; clicks:integer; delta:integer);
begin
  OnMouseWheelDefault(inView, mp, buttons, clicks, delta);
end;

{视图的键盘按下方法
view 视图
value 按键值}
procedure OnKeyDown(var inView:FCView; value:integer);
begin
  OnKeyDownDefault(inView, value);
end;

{视图的键盘抬起方法
view 视图
value 按键值}
procedure OnKeyUp(var inView:FCView; value:integer);
begin
  OnKeyUpDefault(inView, value);
end;

{更新悬浮状态
views:视图集合}
procedure UpdateView(var views:viewArray);
begin
  UpdateViewDefault(views);
end;

{Windows消息循环}
procedure WndProc(hWnd:integer; message:integer; wParam:integer; lParam:integer); cdecl;
begin
  WndProcDefault(appPaint, hWnd, message, wParam, lParam);
end;

procedure CreateUI();
begin
  appPaint.defaultUIStyle := 'dark';
  RenderFaceCat(appPaint, 'mainframe.xml');
end;

begin
  appPaint := FCPaint.Create();
  OnPaintEvent := @OnPaint;
  OnPaintBorderEvent := @OnPaintBorder;
  OnMouseDownEvent := @OnMouseDown;
  OnMouseMoveEvent := @OnMouseMove;
  OnMouseUpEvent := @OnMouseUp;
  OnMouseWheelEvent := @OnMouseWheel;
  UpdateViewEvent := @UpdateView;
  OnClickEvent := @OnClick;
  OnKeyDownEvent := @OnKeyDown;
  OnKeyUpEvent := @OnKeyUp;
  ShowWindow2();
  ShowWindowMax();
  appPaint.hWnd := GetHWnd();
  appPaint.gID := CreateGdiPlus(appPaint.hWnd); 
  appPaint.size := FCSize.Create(getWindowWidth(appPaint.hWnd), getWindowHeight(appPaint.hWnd));
  RegisterWndProc(@WndProc);
  CreateUI();
  PumpMessage();
end.

